#include "seq_stack.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int solution_binary(char *argv);

int main(int argc, char *argv[]) {
  solution_binary(argv[1]);
  return 0;
}

int solution_binary(char *argv) {
  if (argv == NULL) {
    printf("ERROR\n");
    return 0;
  }

  int num = atoi(argv);
  if (num == 0) {
    printf("0\n");
    return 0;
  }
  int temp = num;
  Stack *st;
  stack_init(&st, sizeof(int), 100);
  int data;
  while (temp) {
    data = temp % 2;
    stack_push(st, &data);
    temp /= 2;
  }

  while (stack_empty(st) == 0) {
    printf("%d  ", *(int *)stack_top(st));
    stack_pop(st);
  }
  putchar('\n');
  return 0;
}
